<?php

namespace App\Http\Resources;

use Illuminate\Http\Resources\Json\Resource;

class UserInfoResource extends Resource
{
    /**
     * Transform the resource into an array.
     *
     * @param  \Illuminate\Http\Request $request
     * @return array
     */
    public function toArray($request)
    {
        return [
            'id' => $this->id,
            'mobile' => $this->mobile,
            'student' => new StudentResource($this->whenLoaded('student')),
            'type' => $this->type,
            'teacher_id' => $this->teacher_id,
            'student_id' => $this->student_id,
        ];
    }
}
